<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>节点选择2</title>
    <style>

        .my-div-red {
            background-color: red;
        }

        .my-div-black {
            background-color: black;
        }

    </style>
</head>
<body>
<div id="org">

    <div>
        <span data-id="1234">1234</span>
        <span data-id="1235">1235</span>
        <span data-id="1236">1236</span>
    </div>

</div>
<div>
    <input id="name" name="name" />
    <button id="getName">获取</button>
</div>
</body>
<script src="../../js/jquery-3.4.1.js"></script>
<script>

    let orgCode = '1234';
    $(function () {
        defaultSelect(orgCode);
        buttonInit();
    });

    function defaultSelect(orgCode) {
        $("#org span[data-id=" + orgCode + "]").parent().addClass("my-div-black");
    }

    function buttonInit() {
        $('#getName').click(function () {
            testObj($('#name'));
        });
    }

    function testObj(obj) {
        console.log($(obj).val());
    }

</script>
</html>